package teaching.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class App {

	public static void main(String[] args) {
		// ��ȡѹ������
		ZipInputStream zipInputStream = null;
		File file = new File("d:/test.zip");
		// BufferedReader reader = new BufferedReader(new FileReader("d:/001.txt"));
		//
		// DataInputStream dis = new DataInputStream(new InputStream("d:/aaa.txt"));

		try {
			zipInputStream = new ZipInputStream(new FileInputStream(file));
			ZipEntry zipEntry = null;

			while ((zipEntry = zipInputStream.getNextEntry()) != null) {
				System.out.println(zipEntry.getName());
				zipInputStream.closeEntry();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				zipInputStream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		// // �ļ������
		// FileInputStream fileInputStream = null;
		// ZipOutputStream zipOutputStream = null;
		//
		// try {
		// File file = new File("d:/hello.txt");
		// fileInputStream = new FileInputStream(file);
		//
		// zipOutputStream = new ZipOutputStream(new FileOutputStream("d:/test.zip"));
		// zipOutputStream.putNextEntry(new ZipEntry(file.getName()));
		// zipOutputStream.setComment("Test");
		//
		// int temp = 0;
		// while ((temp = fileInputStream.read()) != -1) {
		// zipOutputStream.write(temp);
		// }
		// } catch (FileNotFoundException e) {
		// e.printStackTrace();
		// } catch (IOException e) {
		// e.printStackTrace();
		// } finally {
		// if (fileInputStream != null) {
		// try {
		// fileInputStream.close();
		// zipOutputStream.close();
		// } catch (IOException e) {
		// e.printStackTrace();
		// }
		// }
		// }

		// Scanner s = new Scanner(System.in);
		// String str = s.nextLine();
		// System.out.println(str);

		// try {
		// RandomAccessFile raf =null;
		// try {
		// File file = new File("d:/002.txt");
		// raf = new RandomAccessFile(file, "rw");
		// raf.seek(raf.length());
		// raf.write("Hello".getBytes());
		// } finally {
		// raf.close();
		// }
		// } catch (FileNotFoundException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// } catch (IOException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }

		// Student stu = new Student(1, "zhangsan", new GregorianCalendar(1997,
		// Calendar.JANUARY, 28).getTime());
		// try {
		// File file = new File("d:/002.txt");
		// FileOutputStream fos = new FileOutputStream(file);
		// ObjectOutputStream oos = new ObjectOutputStream(fos);
		// stu.writeExternal(oos);
		// } catch (FileNotFoundException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// } catch (IOException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }

		// File file = new File("d:/001.txt");
		// try {
		//
		// FileOutputStream fos = new FileOutputStream(file);
		// ObjectOutputStream oos = new ObjectOutputStream(fos);
		// try {
		// oos.writeObject(stu);
		// } finally {
		// oos.close();
		// fos.close();
		// }
		// } catch (IOException e) {
		// e.printStackTrace();
		// }
	}

}
